package ar.com.telefonica.fwk.impl;

import ar.com.telefonica.fwk.EntityDAO;
import ar.com.telefonica.fwk.PersistentEntity;

public abstract class EntityDAOAbstract<T  extends PersistentEntity> extends DAOAbstract<T> implements EntityDAO<T> {

	@SuppressWarnings("unchecked")
	@Override
	public T getByCode(String code) {
		return (T) this.generateQuery("code = " + code).uniqueResult();
	}

	@SuppressWarnings("unchecked")
	@Override
	public T loadByCode(String code){
		T t = (T) this.generateQuery("code = " + code).uniqueResult();
		if (t == null){
			/**
			 * TODO: Crear la excepci�n que sea necesaria
			 */
			//throw new DataAccessException();
		}
		return t;
	}


}
